1. Field of the Invention
The present invention relates to an access apparatus for accessing a semiconductor memory card having internal nonvolatile memory such as EEPROM (electrical erasable programmable read-only memory), a computer-readable recording medium for recording an initialization program for a semiconductor memory card, an initialization method, and a semiconductor memory card, and in particular to an improvement for raising the efficiency with which data can be rewritten in the nonvolatile memory.
2. Description of the Background Art
Semiconductor memory cards have the advantage of being small and lightweight, and are well on the way to consolidating their position as the recording medium of choice in a wide variety of technical fields. A semiconductor memory card has an internalized nonvolatile memory known as EEPROM, which is accessed by a connected device, enabling the semiconductor memory card to be used as a recording medium. Data can be directly written into blank EEPROM sectors in the same way as for magnetic or optical discs. However, when EEPROM sectors already contain data, this data has to be deleted, returning the sectors to a blank state, before new data can be written into the sectors. In the type of EEPROM known as NAND (Not And) used in many semiconductor memory cards, the operation for returning sectors to a blank state has to be performed on 32 sectors at one time (in this nonvolatile memory, a group of 32 sectors is known as an erasable block). Consequently, the semiconductor memory card contains a specialized internal control circuit for realizing memory management using erasable blocks as access units. Status control of erasable blocks, and reading and writing of data to/from erasable blocks, is managed by this control circuit.
This means that the semiconductor memory card has a unique hardware structure (physical layer) that is completely different from that used in magnetic and optical discs. However, a layer model shown in FIG. 1A is formed from physical, file system and application layers, in the same way as in a magnetic or optical disc. FIG. 1B shows a detailed layout of the physical layer. In the drawing, the physical layer includes a volume area, in which a plurality of erasable blocks are arranged. Each erasable block is formed from 32 sectors and has a data length of 16 KB. The layout of the file system layer shown in FIG. 1C is what is commonly known as a FAT (file allocation table) file system. In a FAT file system, management of the volume area is performed in units known as clusters. Volume management information is arranged at the start of the volume area, and a user area for recording user data is arranged directly following the volume management information. The volume management information includes a master boot record, a partition table, a partition boot sector, a duplexed file allocation table (FAT), and a root directory entry. The duplexed FAT shows links between the plurality of clusters included in the volume area. This kind of file system layer enables data to be stored in the application layer in a hierarchical structure formed from directories and files. By installing a layer model, the access apparatus can access a semiconductor memory card with the same procedure used to access a recording medium such as a magnetic or optical disc, without needing to pay attention to differences in the physical layer.
However, a user has many opportunities to determine the data size of the volume area when data is stored in the volume area of the file system. When the size of the volume area is changed in response to a user request, the number of clusters included in the volume area increases or decreases accordingly. If the number of clusters is increased or decreased, the FAT formed from entries corresponding to these clusters also increases or decreases, respectively, as does the size of the volume management information in which the FAT is included. If the size of the volume management information is increased or decreased, a start address of the user area following the volume management information will also be changed. The start address of the user area changes according to the size of the volume area. Consequently, the start addresses of each cluster also change according to the size of the user area.
If the start address of each cluster changes according to the size of the user area, clusters may straddle the boundaries between two erasable blocks, and the end portion of the volume management information may be arranged in the same erasable block as a cluster positioned at the start of the user area. FIG. 1D shows the layout of the volume area when the end portion of the volume management information and the cluster positioned at the start of the user area are in the same erasable block. If clusters are arranged as shown in the drawing, and a user wishes to modify data stored in a particular cluster, the two erasable blocks in which the cluster is arranged have to be read and then returned to a blank state. However, nonvolatile memory is formed from a memory component that includes a floating gate buried in an insulating layer. This memory component can only be erased a few tens of thousands of times, so if the phenomenon in which two erasable blocks have to be erased to modify one cluster frequently occurs, the lifespan of the nonvolatile memory will be significantly reduced.
Generally speaking, when 32 sectors are managed as one cluster, writing data into a cluster can be completed in 32xc3x97200 xcexcs (200 xcexcs is the time required to write each sector), provided that the write destination has already been erased. However, if the write destination has to be erased before data can be written, a 2 ms erasure period is added. If the cluster straddles the boundary between two erasable blocks, both blocks need to be erased, and erasing the write destination takes 4 ms. As a result, the time taken to write data is markedly lengthened.
An object of the present invention is to provide an access apparatus that achieves a reduction in the processing time required to modify erasable blocks, as well as forming a data storage format in a semiconductor memory card that enables a nonvolatile memory having a longer lifespan to be realized.
The type of semiconductor memory card known as a secure digital (SD) memory card has made great strides toward resolving the aforementioned problems of reduction in processing time and nonvolatile memory longevity for the following reasons. In an SD memory card, an area known as the protected area, which cannot be used by the general user, is provided. This protected area is used to store secret information, such as an encryption key used for encrypting data, billing information used to bill a user when a copyrighted material is reproduced, and the like. The amount of data which needs to be kept secret varies according to the type of application program used, so that the size of the protected area has to change according to the type of application program. If the size of the protected area is changed, this means that the layout of the volume area also changes in response to the type of application program. If the layout of the volume area changes in this way, a layout in which clusters straddle the boundaries between erasable blocks is often generated, so achievement of the above-mentioned object is particularly desirable.
In order to achieve the above-mentioned object, the semiconductor memory card access apparatus may have the following structure. The access apparatus performs file access on a semiconductor memory card that has a memory area comprising of a plurality, of sectors by managing data in each group of 2j sectors (j being 0 or a positive integer) as a cluster, and managing one or more clusters as a file. Here, each group of 2i consecutive sectors in the memory area forms a block (i being 0 or a positive integer), which is the smallest unit on which data erasure can be performed. The access apparatus includes a calculation unit, a reserving unit, and a recording unit. The calculation unit calculates a size of volume management information based on a number of clusters in the memory area that are to be managed. Here, the volume management information includes a file allocation table that indicates, for each file, links between clusters corresponding to the file. The reserving unit reserves a first area for recording the volume management information, and a second area for recording user data. The first area has a data size larger than the calculated volume management information, and is formed from mxc3x972j sectors (m being a positive integer), while the second area is formed from sectors following the first area. The recording unit records volume management information in the first area, and user data in the second area, and manages the volume management information and the user data as clusters. In this access apparatus, an area in the volume area having m clusters (m is a positive integer) is reserved for recording volume management information, so there is no possibility of any cluster being stored straddling two erasable blocks. Cluster boundaries can be aligned with erasable block boundaries, and the boundary of the volume management information can be aligned with an erasable block boundary. Consequently, only one erasable block needs to be erased when a cluster is rewritten or overwritten, and the number of times that erasable blocks have to be erased can be reduced. If the number of block erasures is reduced, the semiconductor memory card can write data in a shorter time, and the lifespan of the nonvolatile memory itself can be increased.
Here, the volume management information may include in addition to the file allocation table, a master boot record, a partition table, partition boot sector information, and a root directory entry. Furthermore, the recording unit records the master boot record and the partition table in a first sector of the first area, skips a predetermined number of sectors and then records the partition boot sector information, the file allocation table, and the root directory entry in subsequent sectors. As a result, an end of the first area can be aligned with an end of the root directory entry. The number of sectors between the master boot record showing the start of the drive, and the partition boot sector showing the front of the partition area, can be adjusted, so the volume management information can be restricted to a first area formed from m clusters, and compatibility with devices that use a FAT file system preserved.
Here, the calculation unit may calculate a sum SUM by totaling a number of sectors used to record the partition boot sector information, the file allocation table, and the root directory entry. The reserving unit reserves the first area by calculating the value of m based on an {equation 1} NOM+SUM=2jxc3x97m. Here, NOM is a number of sectors. The recording unit calculates the predetermined number of sectors by subtracting 1 from the number of sectors NOM. Even if the size of the file allocation table changes, a first area which is larger than the size of the volume management information and is an integral multiple of erasable block size is reserved. As a result, a necessary minimum size for the first area can be reserved, no matter how the size of the file allocation table is calculated.
Here, the recording unit may set the predetermined number of sectors in the partition table recording the volume management information. In this structure, even if the size of the first area changes, causing the start address of the second area to change, a number of sectors, obtained by subtracting 1 from the number of sectors NOM, is set in the partition table, so the access apparatus can access the user area accurately by referring to the partition table.